<!--
~  Licensed to the Apache Software Foundation (ASF) under one or more
~  contributor license agreements.  See the NOTICE file distributed with
~  this work for additional information regarding copyright ownership.
~  The ASF licenses this file to You under the Apache License, Version 2.0
~  (the "License"); you may not use this file except in compliance with
~  the License.  You may obtain a copy of the License at
~
~     http://www.apache.org/licenses/LICENSE-2.0
~
~  Unless required by applicable law or agreed to in writing, software
~  distributed under the License is distributed on an "AS IS" BASIS,
~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~  See the License for the specific language governing permissions and
~  limitations under the License.
-->
<div class="flex flex-col">
    <nav class="nifi-registry-navigation select-none">
        <div class="flex justify-between items-center h-[64px] pl-4">
            <div class="flex items-center">
                <div class="ml-2 mr-2 logo-container relative rounded-md">
                    <img
                        ngSrc="assets/icons/registry-logo-web-app.svg"
                        fill
                        priority
                        alt="nifi registry logo"
                        class="pointer p-3"
                        (click)="navigateToResources()" />
                </div>
                <div class="h-[64px] w-[112px] mr-6 relative">
                    <img ngSrc="assets/icons/nifi-logo.svg" fill priority alt="NiFi Logo" />
                </div>
            </div>
            <div class="flex justify-between items-center gap-x-1">
                <div class="flex flex-col justify-between items-end gap-y-1">
                    @if (currentUser(); as user) {
                        @if (user.anonymous) {
                            @if (allowLogin(user)) {
                                <div class="current-user">{{ user.identity }}</div>
                                <a (click)="login()">log in</a>
                            }
                        } @else {
                            <div class="current-user">{{ user.identity }}</div>
                            @if (logoutSupported()) {
                                <a (click)="logout()">log out</a>
                            }
                        }
                    }
                </div>
                <button mat-button [matMenuTriggerFor]="globalMenu" class="global-menu-icon global-menu">
                    <i class="fa fa-navicon text-[32px]"></i>
                </button>
                <mat-menu #globalMenu="matMenu" xPosition="before">
                    <button mat-menu-item class="global-menu-item" (click)="navigateToResources()">
                        <i class="fa mr-2"></i>Resources
                    </button>
                    <button mat-menu-item class="global-menu-item" (click)="navigateToWorkflow()">
                        <i class="fa mr-2"></i>Buckets
                    </button>
                    <button mat-menu-item class="global-menu-item"><i class="fa mr-2"></i>Users/Groups</button>
                    <button mat-menu-item class="global-menu-item" (click)="viewAbout()" [disabled]="!(about$ | async)">
                        <i class="fa fa-info-circle primary-color mr-2"></i>
                        About
                    </button>
                    <a
                        mat-menu-item
                        class="global-menu-item"
                        [href]="documentationUrl"
                        target="_blank"
                        rel="noopener noreferrer">
                        <i class="fa fa-question-circle primary-color mr-2"></i>
                        Documentation
                    </a>
                    <button mat-menu-item [matMenuTriggerFor]="theming">
                        <i class="fa mr-2"></i>
                        Appearance
                    </button>
                    <button mat-menu-item [matMenuTriggerFor]="animations">
                        <i class="fa mr-2"></i>
                        Animations
                    </button>
                </mat-menu>
                <mat-menu #theming="matMenu" xPosition="before">
                    <button
                        mat-menu-item
                        class="global-menu-item"
                        [class.selected]="theme === LIGHT_THEME"
                        (click)="toggleTheme(LIGHT_THEME)">
                        @if (theme === LIGHT_THEME) {
                            <i class="fa fa-check primary-color mr-2"></i>
                        }
                        @if (theme !== LIGHT_THEME) {
                            <i class="fa mr-2"></i>
                        }
                        Light
                    </button>
                    <button
                        mat-menu-item
                        class="global-menu-item"
                        [class.selected]="theme === DARK_THEME"
                        (click)="toggleTheme(DARK_THEME)">
                        @if (theme === DARK_THEME) {
                            <i class="fa fa-check primary-color mr-2"></i>
                        }
                        @if (theme !== DARK_THEME) {
                            <i class="fa mr-2"></i>
                        }
                        Dark
                    </button>
                    <button
                        mat-menu-item
                        class="global-menu-item"
                        [class.selected]="theme === OS_SETTING"
                        (click)="toggleTheme(OS_SETTING)">
                        @if (theme === OS_SETTING || theme === null) {
                            <i class="fa fa-check primary-color mr-2"></i>
                        }
                        @if (theme !== OS_SETTING && theme !== null) {
                            <i class="fa mr-2"></i>
                        }
                        Device
                    </button>
                </mat-menu>
                <mat-menu #animations="matMenu" xPosition="before">
                    <button
                        mat-menu-item
                        class="global-menu-item"
                        [class.selected]="disableAnimations === 'false'"
                        (click)="toggleAnimations('false')">
                        @if (disableAnimations === 'false') {
                            <i class="fa fa-check primary-color mr-2"></i>
                        } @else {
                            <i class="fa mr-2"></i>
                        }
                        Enabled
                    </button>
                    <button
                        mat-menu-item
                        class="global-menu-item"
                        [class.selected]="disableAnimations === 'true'"
                        (click)="toggleAnimations('true')">
                        @if (disableAnimations === 'true') {
                            <i class="fa fa-check primary-color mr-2"></i>
                        } @else {
                            <i class="fa mr-2"></i>
                        }
                        Disabled
                    </button>
                    <button
                        mat-menu-item
                        class="global-menu-item"
                        [class.selected]="disableAnimations === null"
                        (click)="toggleAnimations()">
                        @if (disableAnimations === null) {
                            <i class="fa fa-check primary-color mr-2"></i>
                        } @else {
                            <i class="fa mr-2"></i>
                        }
                        Device
                    </button>
                </mat-menu>
            </div>
        </div>
    </nav>
</div>
